
// Plugin for DarkRP 2.3.5

PLUGIN.Name = "darkrp_235"
PLUGIN.Author = "[GU]thomasfn"
PLUGIN.Version = "1.0.0"

PLUGIN.JobDesc = [[You are a specialised computer technician.
	You help other people setup their computers.
	You buy computer equipment for other people.
	Use '!pcbuy' to purchase equipment.
	Use your install disk to install software.
	Charge other people for your services!]];
PLUGIN.JobSweps = { "pcmod_pwcrack", "pcmod_hdcopier", "pcmod_wireswep", "pcmod_unwireswep" }
PLUGIN.JobSalary = 80
PLUGIN.JobColour = Color( 100, 100, 0, 255 )

function PLUGIN:IsDarkRP()
	// Is the gamemode DarkRP?
	if (SERVER) then
		return ((DARKRPVERSION) && (DARKRPVERSION == "2.3.5"))
	end
	if (CLIENT) then
		return ((DrawPlayerInfo) && (DrawPriceInfo) && (DrawShipmentInfo))
	end
end

function PLUGIN:Hook( hookname, ... )
	if (hookname == "pre_load") then
		self:BeforeLoad()
	end
	if (hookname == "post_load") then
		// self:AfterLoad()
	end
	if (hookname == "timed_delay") then
		self:AfterLoad()
	end
end

function PLUGIN:BeforeLoad()
	PCMod.Msg( ">> DarkRP 2.3.5 PCMod Plugin " .. self.Version .. " Pre-Loaded! <<" )
end

function PLUGIN:AfterLoad()
	if (self:IsDarkRP()) then
		if (SERVER) then
			PCMod.RP.GetMoney = function( ply )
				PCMod.Msg( "About to retrieve money...", true )
				return tonumber( DB.RetrieveMoney( ply ) )
			end
			PCMod.RP.CanBuy = function( ply, entclass )
				PCMod.Msg( "About to determine CanBuy()...", true )
				return (ply:Team() == TEAM_COMPTECH)
			end
			PCMod.RP.CanBuyPack = function( ply, entclass )
				PCMod.Msg( "About to determine CanBuyPack()...", true )
				return (ply:Team() == TEAM_COMPTECH)
			end
			PCMod.RP.DeductMoney = function( ply, amount )
				PCMod.Msg( "Deducting '" .. amount .. "' from '" .. ply:Nick() .. "'!", true )
				ply:AddMoney( -amount )
			end
		end
		PCMod.Cfg.RPMode = true
		PCMod.Msg( ">> DarkRP 2.3.5 PCMod Plugin " .. self.Version .. " Post-Loaded! <<" )
	else
		PCMod.Msg( ">> DarkRP 2.3.5 PCMod Plugin " .. self.Version .. " Post-Loaded! (NO DARKRP)<<" )
	end
end

function PLUGIN:SetupJob()
	local res = AddExtraTeam( "Computer Technician", self.JobColour, "models/player/eli.mdl",
			self.JobDesc, self.JobSweps, "comptech", 2, self.JobSalary, 0, false );
	
	return res
end